﻿using Server.MessageModule;
using Server.MessageModule.Message;
using Server.MessageModule.MessageProcessor;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Server.Core
{
    public class Manager : IMessageReceiptable
    {
        private MessageDispatcher _msgDispatcher;

        public IMessageDispatcher MessageDispatcher { get { return _msgDispatcher; } }

        public Manager()
        {
        }

        public void init()
        {
            // init processor
            SensorProcessor sensorProc = new SensorProcessor();
            CommandProcessor commandProc = new CommandProcessor();

            _msgDispatcher = new MessageDispatcher();
            _msgDispatcher.addMessageProcessor(sensorProc);
            _msgDispatcher.addMessageProcessor(commandProc);
        }


        public void onReceiptMessage(INetworkMessage msg)
        {
            if (msg != null)
            {
                _msgDispatcher.dispatchMessage(msg);
            }
        }

    }
}
